﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Directory.Web
{
	public partial class ChangePassword : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{

		}

		protected void btnChangePwd_Click(object sender, EventArgs e)
		{
			if (tbPassword.Text != tbVerifyPwd.Text)
			{
				ltMsg.Text = "两次输入新密码不匹配。";
				return;
			}
			if (!UserDataProxy.ValidatePassword(Page.User.Identity.Name, tbRawPassword.Text))
			{
				ltMsg.Text = "密码错误。";
			}
			else
			{
				try
				{
					UserDataProxy.ResetPassword(Page.User.Identity.Name, tbPassword.Text);
					ltMsg.Text = "设置成功。";
				}
				catch(Exception ex)
				{
					ltMsg.Text = "设置失败："+ex.Message;
				}
			}
		}
}
}